<!--
 * @Description: file content
 * @Author: oooh
 * @Date: 2024-05-10 09:35:32
 * @LastEditors: oooh
 * @LastEditTime: 2024-05-15 14:49:34
 * @FilePath: \Civil_Servant_Performance_PC\src\components\ApprovalLog\index.vue
-->
<template>
  <el-popover :placement="placement" :title="title" trigger="hover" @show="popoverShow" :disabled="popoverDisabled">
    <div class="popper-container">
      <el-timeline reverse>
        <el-timeline-item v-for="activity in activities" :key="activity.id" :timestamp="activity.auditTime" color="#409EFF">
          <dict-tag :options="dict.type.biz_audit_status" :value="activity.auditStatusDict"></dict-tag>
          <p>{{ activity.nodeName }}:{{ activity.auditRemark || '-' }}</p>
        </el-timeline-item>
      </el-timeline>
      <span v-if="!activities.length">---</span>
    </div>

    <template slot="reference">
      <slot></slot>
    </template>
  </el-popover>
</template>

<script>
import { approvalLogs } from '@/api/work-approval'
export default {
  name: 'approval-log',
  dicts: ['biz_audit_status'],
  props: {
    bizId: {
      type: [String, Number],
      default: ''
    },
    title: {
      type: String,
      default: '审批记录'
    },
    placement: {
      type: String,
      default: 'bottom-end'
    }
  },
  components: {},
  data() {
    return {
      activities: [],
      popoverDisabled: false
    }
  },
  computed: {},
  watch: {},
  methods: {
    aduitContentFormat() {},
    popoverShow() {
      this.popoverDisabled = true
      if (!this.bizId) return
      approvalLogs({ bizId: this.bizId }).then(res => {
        this.activities = res.data
        this.popoverDisabled = res.data.length ? false : true
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.popper-container {
  width: 250px;
  max-height: 250px;
  padding: 10px;
  box-sizing: border-box;
  overflow-y: auto;
  ul {
    padding: 0;
  }
}
</style>
